<template>
	<view class="fullContent bgf8">
		<view class="inputWrap bgw">
			<textarea :placeholder="placeholder" v-model="content" @input="handleInput"></textarea>
			<view>已输入<text>{{content.length}}</text>个字</view>
		</view>
		<view class="btnStyle" @click="submit">完成</view>
	</view>
</template>

<script>
	import {
		update
	} from '../../request/api.js'
	export default {
		data() {
			return {
				id:'',
				type:'',
				content: '',
				placeholder: '',
			};
		},
		onLoad(options) {
			this.type = options.type
			this.id = options.id
			let title
			if (options) {
				if (options.type === 'pro') {
					title = '专业擅长'
					this.placeholder = '请填写您的专业擅长'
				} else {
					title = '个人简介'
					this.placeholder = '请填写您的个人详细信息，比如您的学历经历、职业经历，参与的项目，取得的成就、奖项等。'
				}
				uni.setNavigationBarTitle({
					title: title
				})
			}
		},
		methods: {
			handleInput(e) {
				this.content = e.target.value
			},
			submit() {
				let param = {}
				if(!this.content){
					uni.showToast({
						title:'请输入内容',
						icon:'none'
					})
					return
				}
				if(this.type == 'pro'){
					param = {
						id:this.id,
						sc:this.content
					}
				}else if(this.type == 'pra'){
					param = {
						id:this.id,
						comment:this.content
					}
				}
				update(param).then(res => {
					uni.showToast({
						title:'操作成功',
						icon:'none'
					})
					setTimeout(function(){
						uni.navigateBack({
							delta: 1
						})
					},600)
				})
			}
 		}
	}
</script>

<style lang="scss" scoped>
	.inputWrap {
		height: 432upx;
		padding:40upx 30upx 18upx;
		margin-bottom: 80upx;
		textarea{
			width: 100%;
			margin-bottom: 40upx;
		}
		>view{
			font-size: 24upx;
			text-align: right;
			
			color: #9F9F9F;
			text{
				color: #F86C53;
			}
		}
	}

	.btnStyle {
		margin: 0 auto;
	}
</style>
